/*
 * Copyright (C) 2010-2014 Enrique Lara (enrique.posix2.lara@gmail.com)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package trs.wmata;

import android.content.Context;

import app.transittool.R;

import app.transittool.model.Route;
public enum TrainLine {
    BLUE(R.string.blue, "BL", R.drawable.blue, R.array.destinations_blue, R.array.destinations_blue_cd),
    GREEN(R.string.green, "GR", R.drawable.green, R.array.destinations_green, R.array.destinations_green_cd),
    ORANGE(R.string.orange, "OR", R.drawable.orange, R.array.destinations_orange, R.array.destinations_orange_cd),
    RED(R.string.red, "RD", R.drawable.red, R.array.destinations_red, R.array.destinations_red_cd),
    SILVER(R.string.silver, "SV", R.drawable.silver, R.array.destinations_silver, R.array.destinations_silver_cd),
    YELLOW(R.string.yellow, "YL", R.drawable.yellow, R.array.destinations_yellow, R.array.destinations_yellow_cd),
    UNKNOWN(R.string.unknown, "UNKNOWN", R.drawable.ic_transit_alarm, R.array.destinations_unknown, R.array.destinations_unknown);
    private final int nameId;
    private final String code;
    private final int imageId;
    private final int directionNamesArrayId;
    private final int directionCodesArrayId;

    private TrainLine(final int nameId, final String code, final int imageId, final int directionArrayId, final int directionCodesArrayId) {
        this.nameId = nameId;
        this.code = code;
        this.imageId = imageId;
        directionNamesArrayId = directionArrayId;
        this.directionCodesArrayId = directionCodesArrayId;
    }

    public int getNameId() {
        return nameId;
    }

    public String getCode() {
        return code;
    }

    public int getImageId() {
        return imageId;
    }

    protected int getDirectionNamesArrayId() {
        return directionNamesArrayId;
    }

    protected int getDirectionCodesArrayId() {
        return directionCodesArrayId;
    }

    public Route newInstance(final Context context) {
        return new Route() {
                @Override
                public String getCode() {
                    return TrainLine.this.getCode();
                }

                @Override
                public String[] getDirectionNames() {
                    return context.getResources().getStringArray(TrainLine.this.getDirectionNamesArrayId());
                }

                @Override
                public String[] getDirectionCodes() {
                    return context.getResources().getStringArray(TrainLine.this.getDirectionCodesArrayId());
                }

                @Override
                public int getImageId() {
                    return TrainLine.this.getImageId();
                }

                @Override
                public String getName() {
                    return context.getString(TrainLine.this.getNameId());
                }
            };
    }
}
